﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace DesignByContract.CodeContracts
{
    [ContractClass(typeof(DefaultOperationClass))]
    public interface IInterest
    {
        double ComputeInterest(double amount, double rate);
    }

    [ContractClassFor(typeof(IInterest))]
    internal abstract class DefaultOperationClass : IInterest
    {
        public double ComputeInterest(double amount, double rate)
        {
            //Pre-Condition
            Contract.Requires(rate < 1, "Interest rate must be less than 1.");
            
            //Post-Condition
            Contract.Ensures(Contract.Result<double>() > amount, "Amount after interest must be superior to initial amount.");

            //Dummy Value, this method only serves to add additional contracts
            return 0;
        }
    }
}
